﻿@{
	Layout = null;
	ViewBag.MaxFileSizeOfM = 10;
	ViewBag.Exts = ".bmp,.jpg,.jpeg,.gif,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.wps,.pdf,.7z,.zip,.rar";
	ViewBag.ImageThumbnails = "true";
}

<!DOCTYPE html>
<html>
<head>
	<title>上传</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link href="~/lib/dropzone/basic.min.css" rel="stylesheet" asp-append-version="true" />
	<link href="~/lib/dropzone/dropzone.min.css" rel="stylesheet" asp-append-version="true" />
	@*<link href="~/lib/bootstrap/bootstrap-3.3.7.min.css" rel="stylesheet" asp-append-version="true" />
	<link href="~/lib/adminlte/css/adminlte-2.4.8.min.css" rel="stylesheet" asp-append-version="true" />
	<link href="~/lib/adminlte/css/skins/skin-blue.min.css" rel="stylesheet" asp-append-version="true" />
	<link href="~/lib/font-awesome/font-awesome.min.css" rel="stylesheet" asp-append-version="true" />*@
	<style>
		.dropzone .dz-message {
			line-height: 260px;
			margin: 0;
		}

		.dropzone {
			min-height: 320px;
		}
	</style>
</head>
<body>
	<div class="dropzone needsclick dz-clickable" id="dropzoneForm" style="border: 2px dashed #0087F7; border-radius: 5px; text-align: center;">
		<div class="fallback">
			<input name="file" type="file" multiple />
			<input type="submit" value="Upload" />
		</div>

	</div>
	@*<div style="text-align: center; margin-top: 10px;">
	<button class="btn btn-primary" id="btnUpload" onclick="doUpload();return false;" style="margin-right: 80px;">
	<i class="icon-upload"></i>上传
	</button>
	<button class="btn btn-warning" id="btnCancel" onclick="window.close();return false;">
	<i class="icon-remove"></i>取消
	</button>
	</div>*@
	<script src="~/lib/dropzone/dropzone.min.js" asp-append-version="true"></script>
	<script type="text/javascript">
		Dropzone.autoDiscover = false;
		var myDropzone = new Dropzone("#dropzoneForm", {
			maxFiles: 10,
			dictMaxFilesExceeded: '最大上传文件数为1',
			parallelUploads: 10,//同时上传最大文件数
			maxFilesize: @ViewBag.MaxFileSizeOfM,//M
			url: "@Url.Action("UploadToBind", "Sys_Attachment")",
			params: { tblid: "@(ViewData["tblid"])", infoid: "@(ViewData["infoid"])" },
			addRemoveLinks: true,
			dictRemoveFile: '删除',
			dictCancelUpload: '取消上传',
			dictCancelUploadConfirmation: '文件正在上传中，取消上传可能会造成数据有误，确定取消吗？',
			createImageThumbnails: @ViewBag.ImageThumbnails,
			acceptedFiles: '@ViewBag.Exts',
			autoProcessQueue: true,
			dictDefaultMessage: '拖动文件到此处上传或点击此处选择文件上传',
			dictInvalidFileType: '不支持此类文件',
			init: function () {
				this.on("maxfilesexceeded", function (file) {
					//var files = this.getQueuedFiles();
					//myDropzone.removeFile(files[0]);
					myDropzone.removeFile(file);
					//myDropzone.addFile(file);
				});
				this.on("success", function (file, ret) {
					if (ret.r) {
						if (window.opener && window.opener.@(ViewData["callback"])) {
					window.opener.@(ViewData["callback"])(ret.data, @(ViewData["ext"]));
				}
				if (window.parent && window.parent.@(ViewData["callback"])) {
					window.parent.@(ViewData["callback"])(ret.data, @(ViewData["ext"]));
								}
		myDropzone.removeFile(file);
							}
						});
		this.on("complete", function (file) {
		});
		this.on('queuecomplete', function () {
			window.close();
		});

					}
				});
	</script>
</body>
</html>
